//
//  BaseViewController.m
//  美团外卖
//
//  Created by Alex on 16/9/23.
//  Copyright © 2016年 Alex. All rights reserved.
//

#import "BaseViewController.h"
#import "LBNavBarView.h"

@interface BaseViewController ()

@property (nonatomic, weak) LBNavBarView *navBarView;

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];
}

#pragma mark
#pragma mark - 初始化界面
- (void)setupUI {
    
    self.view.backgroundColor  = [UIColor whiteColor];
    
    // 设置返回按钮的显示
    
    // 让文字显示为空
//    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"" style:UIBarButtonItemStyleDone target:nil action:nil];
    
    // 修改系统的返回图片 , 两个方法必须同时设置, 否则无效
//    [self.navigationController.navigationBar setBackIndicatorImage:[UIImage imageNamed:@"btn_backItem"]];
//    [self.navigationController.navigationBar setBackIndicatorTransitionMaskImage:[UIImage imageNamed:@"btn_backItem"]];
    
    //    // 设置文字的颜色--> 白色
    //    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    //
    //    // 设置导航栏的渲染颜色
    //    [self.navigationController.navigationBar setTintColor:[UIColor colorWithWhite:1 alpha:1]];
    
    //等同于上面两句
    //self.navTintGradien = 1;
}

#pragma mark
#pragma mark - 懒加载自定义导航条视图
- (LBNavBarView *)navBarView {
    
    if (nil == _navBarView) {
        
        LBNavBarView *navBarView = [[LBNavBarView alloc]initWithFrame:CGRectMake(0, 0, kScreenSize.width, 64)];
        
        _navBarView = navBarView;
        
        // 默认透明度
        navBarView.alpha = 0;
        
        [self.view addSubview:navBarView];
        
    }
    
    return _navBarView;
}


#pragma mark
#pragma mark - 重写设置透明度的set方法
- (void)setNavBarViewAlpha:(CGFloat)navBarViewAlpha {
    
    _navBarViewAlpha = navBarViewAlpha;
    
    self.navBarView.alpha = navBarViewAlpha;
    
    
}

#pragma mark
#pragma mark - 重写设置导航栏的渲染颜色和文字颜色的set方法
- (void)setNavTintGradien:(CGFloat)navTintGradien {
    _navTintGradien = navTintGradien;
    
    // 设置文字的颜色
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithWhite:navTintGradien alpha:1]}];
    
    // 设置导航栏的渲染颜色
    [self.navigationController.navigationBar setTintColor:[UIColor colorWithWhite:navTintGradien alpha:1]];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
